using System.Collections;
using System.Data;
using System.Linq;

namespace Nvigorate.Test.Data.Doubles
{
    public class TestDataParameterCollection : CollectionBase, IDataParameterCollection
    {
        public bool Contains(string parameterName)
        {
            return List.Cast<IDataParameter>().ToList().Exists(p => p.ParameterName == parameterName);
        }

        public int IndexOf(string parameterName)
        {
            return List.Cast<IDataParameter>().ToList().FindIndex(p => p.ParameterName == parameterName);
        }

        public void RemoveAt(string parameterName)
        {
            List.RemoveAt(IndexOf(parameterName));
        }

        public object this[string parameterName]
        {
            get { return List.Cast<IDataParameter>().FirstOrDefault(p => p.ParameterName == parameterName); }
            set { List.Add(value); }
        }
    }
}